import { service, cameraService, WEBRTC_STREAM_URL } from './index';


// 缺陷接口
export function listFlaw(params) {
    return service.get('/agv/flaw/list', { params });
}

export function getFlaw(id) {
    return service.get(`/agv/flaw/${id}`);
}

export function addFlaw(data) {
    return service.post('/agv/flaw', data);
}

export function updateFlaw(data) {
    return service.put('/agv/flaw', data);
}

export function delFlaw(id) {
    return service.delete(`/agv/flaw/${id}`);
}

export function getLiveFlawInfo(id) {
    return service.get(`/agv/flaw/live/${id}`);
}

export function checkAllFlawsConfirmed(id) {
    return service.get(`/agv/flaw/check/${id}`);
}


// AGV移动
export function getHeartbeat() {
    return service.get('/agv/movement/heartbeat');
}

export function agvForward() {
    return service.post('/agv/movement/forward');
}

export function agvStop() {
    return service.post('/agv/movement/stop');
}

export function agvBackward() {
    return service.post('/agv/movement/backward');
}


// 系统检查
export function checkFs() {
    return service.get('/system/check/fs');
}

export function checkDb() {
    return service.get('/system/check/db');
}

export function checkAgv() {
    return service.get('/system/check/agv');
}

export function checkCam() {
    return service.get('/system/check/cam');
}

// 摄像头管理
export function getDeviceList(params = { page: 1, size: 999 }) {
    return cameraService.get('/devices', { params });
}

export function getVideoStreamUrl(cameraId) {
    // 根据WebRTC流媒体文档拼接完整的视频流URL
    // 格式: {流媒体服务}/live/{摄像头ID}_01.flv
    return `${WEBRTC_STREAM_URL}/live/${cameraId}_01.flv`;
}